<%
	//dbcon

	$tipe = $_REQUEST['tipe'];
	$field = $_REQUEST['field'];
	$available = 1;
	if(strlen($field) <= 0)
	{
	  out.println( json_encode(array('code'  =>  -1,
	  'result'  =>  'Isi dahulu input field'
	  )));
	}else{
		$qres = mysql_query("SELECT * FROM user");
		while($row = mysql_fetch_array($qres))
		{
			if ($tipe==1){
				if (strcmp($row['username'],$field)==0) $available=0;
			}else{
				if (strcmp($row['email'],$field)==0) $available=0;
			}
		}
		if($available==1)
		{
			out.println( json_encode(array('code'  =>  1,
			'result'  =>  "Username : ".$field." dapat digunakan."
			)));
			die;
		}else{
			out.println(  json_encode(array('code'  =>  0,
			'result'  =>  "Maaf username : ".$field." sudah terdaftar."
			)));
		}
	}
%>